<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="bs" class="weaver.general.BaseBean"/>
<%
    //接收参数
    String requestid = Util.null2String(request.getParameter("requestid"));
    String type = Util.null2String(request.getParameter("type"));//类型  1：请假  2：加班 3：外出 4:出差

    String id =  request.getParameter("id");//姓名
    new BaseBean().writeLog("========人员姓名："+id+"类型："+type);
    if(null == id){
        id = java.net.URLDecoder.decode(id, "utf-8");
    }
    
    String startTime =  request.getParameter("startTime");//开始时间
    String endTime = request.getParameter("endTime");//结束时间

    String days =  Util.null2String(request.getParameter("days"));//请假天数
    String leaveType =  Util.null2String(request.getParameter("leaveType"));//请假类型
    //准备参数

    if(null == startTime||null == endTime){
        String startDate = startTime.split(" ")[0];
        startTime = startTime.split(" ")[1];
        String endDate = endTime.split(" ")[0];
        endTime = endTime.split(" ")[1];
    }
   
%>

<%
    RecordSet rs = new RecordSet();
    String sql = "";
    PrintWriter writer = response.getWriter();
    //处理参数
    //查询人员id
    sql = "select id from hrmresource where loginid = '"+id+"'";
    rs.execute(sql);
    if (rs.next()){
        id = Util.null2String(rs.getString("id"));
    }else {
        return;
    }
    //查询请假类型
    sql = "";

    if ("1".equals(type)){
        //请假


       //查询人员请假事由
//        sql = "select xjyy2 from formtable_main_2 where ksrq = '"+startDate+"' and kssj = '"+startTime+"' and jsrq = '"+endDate+"' and jssj = '"+endTime+"' and sqr = '"+id+"'  and qjlx = '"+leaveType+"' and ts = '"+days+"'";
        sql = "select xjyy2 from formtable_main_2 where ksrq = '"+startDate+"' and kssj = '"+startTime+"' and jsrq = '"+endDate+"' and jssj = '"+endTime+"' and sqr = '"+id+"' and ts = '"+days+"'";
        new BaseBean().writeLog("查询SQL："+sql);
        rs.execute(sql);
        if(rs.next()){
            //请假事由
            String qjsy = rs.getString("xjyy2");
            writer.write(qjsy);
            writer.close();
            return;
        }
    }else if("2".equals(type)){
        //加班
        //查询该流程的加班事由
        sql = "select jbsy from formtable_main_17 where requestid = '"+requestid+"'";
        rs.execute(sql);
        if (rs.next()){
            String jbsy = rs.getString("jbsy");
            writer.write(jbsy);
            writer.close();
            return;
        }
    }else if("3".equals(type)){
        sql = "select * from formtable_main_27 where rq = '"+startDate+"' and wcsj = '"+startTime+"' and hgssj='"+endTime+"' and sqr = '"+id+"'";
        new BaseBean().writeLog("========公出查询SQL："+sql);
        rs.execute(sql);
        if (rs.next()){
            String wcsy = rs.getString("wcsy");
            writer.write(wcsy);
            writer.close();
            return;
        }
    }else if ("4".equals(type)){
//        String reslut = "";
        sql = "select ccdd,bz from formtable_main_18 where qsrq = '"+startDate+"' and qssj = '"+startTime+"' and jsrq = '"+endDate+"' and jssj = '"+endTime+"' and ccsqr = '"+id+"'";
        new BaseBean().writeLog("========出差查询SQL："+sql);
        rs.execute(sql);
        if (rs.next()){
//            String ccdd = "地点"+rs.getString("ccdd")+",备注："+rs.getString("bz");
            String ccdd = rs.getString("ccdd");
            new BaseBean().writeLog("========出差地点："+ccdd);
            writer.write(ccdd);
            writer.close();
            return;
        }

    }


%>